package com.huike.review.service.impl;

import com.github.pagehelper.Page;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.exception.CustomException;
import com.huike.common.utils.bean.BeanUtils;
import com.huike.review.pojo.Review;
import com.huike.review.service.ReviewService;
import com.huike.review.mapper.MybatisReviewMapper;
import com.huike.review.vo.MybatisReviewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * mybatis复习使用的业务层
 * 注意该业务层和我们系统的业务无关，主要是让同学们快速熟悉系统的
 */
@Service
public class ReviewServiceImpl implements ReviewService {

    @Autowired
    private MybatisReviewMapper reviewMapper;

    //根据id查询
    @Override
    public Review findById(Long id) {
        Review review = reviewMapper.findById(id);
        return review;
    }
    //分页查询
    @Override
    public Page<Review> findByPage(Integer pageNum, Integer pageSize) {
        //设置分页条件
       Page<Review> page = new Page<>(pageNum,pageSize);
       page = reviewMapper.selectPage(page);

        return page;
    }
    //新增
    @Override
    public void saveData1(String name,Integer age, String sex) {

        reviewMapper.saveData1(name,age,sex);
    }
    //新增2
    @Override
    public void saveData2(Review review) {

        reviewMapper.saveData2(review);
    }
    //修改通过id
    @Override
    public void updateById(Review review) {

         reviewMapper.update(review);



    }
    //根据id删除
    @Override
    public void deleteById(Integer id) {
        reviewMapper.deleteById(id);
    }


}
